//
//  VisitorTableViewController.swift
//  JLWeibo
//
//  Created by sunjinliang on 15/12/6.
//  Copyright © 2015年 sunjinliang. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

 
    }
    var userLogon = UserAccountVM.shareUserAccount.userLogon
    var visitorView: visitor?
    override func loadView() {
        userLogon ? super.loadView() : setupVieitorView()
    }
    
    private func setupVieitorView(){
        visitorView = visitor()
        visitorView?.registerBtn.addTarget(self, action:"visitorViewDidRegister" , forControlEvents: .TouchUpInside)
         visitorView?.loginBtn.addTarget(self, action:"visitorViewDidLogin" , forControlEvents: .TouchUpInside)
        view = visitorView
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidLogin")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidRegister")
    }

}
extension VisitorTableViewController {
    func visitorViewDidRegister() {
        print("register ")
    }
    func visitorViewDidLogin() {
        print("longin")
        let oath = OAuthViewController()
        let na = UINavigationController(rootViewController: oath)
        presentViewController(na, animated: true, completion: nil)
    }
}